package com.softserveinc.moviedbapp.connection;

import android.util.Log;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class InputStreamProvider {

	private static String TAG = InputStreamProvider.class.getSimpleName();

	private int readTimeout = 12000;

	public InputStream getInputStream(final String url) throws IOException {
		Log.d(TAG, "inside getInputStream()");
		InputStream inputStream = null;

		try {
			URL apiUrl = new URL(url);
			URLConnection conn = apiUrl.openConnection();
			conn.setReadTimeout(readTimeout);
			conn.connect();
			inputStream = conn.getInputStream();
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			Log.e(TAG, "TT", e);
		}
		return inputStream;
	}
}
